package com.demo.project_template.service.impl;

import com.demo.project_template.constant.OrderConstants;
import com.demo.project_template.entity.AfterSalesOrder;
import com.demo.project_template.entity.Order;
import com.demo.project_template.mapper.AfterSalesOrderMapper;
import com.demo.project_template.mapper.OrderMapper;
import com.demo.project_template.service.AfterSalesOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.project_template.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 杨玉龙
 * @since 2023-06-19 15:56:43
 */
@Service
public class AfterSalesOrderServiceImpl extends ServiceImpl<AfterSalesOrderMapper, AfterSalesOrder> implements AfterSalesOrderService {

    @Resource
    private AfterSalesOrderMapper afterSalesOrderMapper;
    @Resource
    private OrderMapper orderMapper;
    @Resource
    private OrderService orderService;

    @Override
    public void insertAfterSalesOrder(AfterSalesOrder afterSalesOrder) {
//        afterSalesOrder.setStatue(OrderConstants.ORDER_STATUS_NO);
//        afterSalesOrderMapper.insert(afterSalesOrder);
//        Order order = orderMapper.selectById(afterSalesOrder.getOrderId());
//        order.setOrderStatus(OrderConstants.ORDER_STATUS_AFTERSALES);
//        orderMapper.updateById(order);
    }

    @Override
    public void updateAfterSalesOrder(Integer afterSalesOrderId) {
//        AfterSalesOrder afterSalesOrder = afterSalesOrderMapper.selectById(afterSalesOrderId);
//        Order order = orderMapper.selectById(afterSalesOrder.getOrderId());
//        orderService.refundOrder(order.getOrderNo(),order.getPayPrice());
//        afterSalesOrder.setStatue(OrderConstants.ORDER_STATUS_FINISH);
//        afterSalesOrderMapper.updateById(afterSalesOrder);
//        order.setOrderStatus(OrderConstants.ORDER_STATUS_REFUND);
//        orderMapper.updateById(order);

    }
}
